﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Apps.ServiceImpl.Attendance.Repositories.Interface;
using EzDesk.Apps.Model.Attendance;

namespace EzDesk.Apps.ServiceImpl.Attendance.Repositories
{
    public class LegalHolidayRepository : ILegalHolidayRepository
    {
        EzDeskAttendanceDataContext _db;

        public LegalHolidayRepository(EzDeskAttendanceDataContext db)
        {
            this._db = db;
        }

        public LegalHoliday GetLegalHolidayInfo(DateTime date)
        {
            return (from l in _db.ez_LegalHolidays
                    where l.StartDay <= date && date <= l.EndDay
                    select new LegalHoliday()
                    {
                        Id = l.HolidayId,
                        Year = l.Year,
                        StartDate = l.StartDay,
                        EndDate = l.EndDay,
                        Name = l.HolidayName,
                        Remark = l.Remark
                    }).SingleOrDefault();

        }

        public Guid Add(LegalHoliday model, bool saveChanges)
        {
            throw new NotImplementedException();
        }

        public LegalHoliday GetById(Guid id)
        {
            throw new NotImplementedException();
        }

        public IQueryable<LegalHoliday> GetAll()
        {
            throw new NotImplementedException();
        }

        public void Delete(Guid id, bool saveChanges)
        {
            throw new NotImplementedException();
        }

        public void Update(LegalHoliday model, bool saveChanges)
        {
            throw new NotImplementedException();
        }

        public void SaveChanges()
        {
            _db.SubmitChanges();
        }
    }
}
